package com.maybach.core.manager.impl;

import com.maybach.util.query.support.PageResult;
import com.maybach.common.model.PartnerDO;
import com.maybach.common.query.PartnerQuery;
import com.maybach.core.dal.mapper.ext.PartnerExtMapper;
import com.maybach.core.manager.PartnerManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.SQLException;
import java.util.List;


/**
 * Manager for Partner.
 */

@Component
public class PartnerManagerImpl implements PartnerManager{
    protected Logger log = LoggerFactory.getLogger(this.getClass());

    
    @Autowired
    protected PartnerExtMapper partnerMapper;
    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(PartnerQuery query){
        return partnerMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(PartnerQuery query){
        return partnerMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(PartnerDO record){
        return partnerMapper.deleteByPrimaryKey(record);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(PartnerDO record){
        return partnerMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<PartnerDO> selectByQuery(PartnerQuery query){
        return partnerMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
    */
    @Override
    public PageResult<PartnerDO> selectByQueryWithPage(PartnerQuery query) {
        PageResult<PartnerDO> result = new PageResult<PartnerDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public PartnerDO selectByPrimaryKey(Long id){
        return partnerMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective( PartnerDO record,  PartnerQuery query){
        return partnerMapper.updateByQuerySelective(record,  query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery( PartnerDO record,  PartnerQuery query){

        return partnerMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(PartnerDO record){
        return partnerMapper.updateByPrimaryKeySelective(record);
    }

    /**
     * 根据组织机构代码查询公司数量
     *
     * @param certificateCode
     * @return
     * @throws SQLException
     */
    @Override
    public int countPartnerByCertificateCodeDao(String certificateCode) throws SQLException {
        return partnerMapper.countPartnerByCertificateCodeDao(certificateCode);
    }
}